package com.qf.usermanageradmin.utils;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 处理登录异常
     */
    @ExceptionHandler(NoUserException.class)
    public R handleNoUserException(NoUserException e){
        return R.error("用户不存在");
    }

    /**
     * 处理拒绝访问异常
     */
    @ExceptionHandler(AccessDeniedException.class)
    public R handleAccessDeniedException(AccessDeniedException e){
        return R.error("没有登录,拒绝访问!");
    }
}
